<template>

 <div class="mod-config">
    <h2 style="text-align: center;">添加球员信息</h2>

    <el-steps :active="1" process-status="wait" align-center style="margin-bottom: 40px;">
      <el-step title="球员信息"/>
      <el-step title="球员常规赛基础数据"/>
      <el-step title="球员常规赛进阶数据"/>
    </el-steps>

    <el-form  :model="list" label-width="100px"
    width="100" :inline="true" class="demo-form-inline" style="margin-left:10%">
  <el-form-item label="球员名字" >
    <el-input v-model="list.english" ></el-input>
  </el-form-item>
  <el-form-item label="球员中文名">
    <el-input v-model="list.name"></el-input>
  </el-form-item>
  <el-form-item label="身高">
    <el-input v-model="list.height"></el-input>
  </el-form-item>
   <el-form-item label="体重">
    <el-input v-model="list.weight"></el-input>
  </el-form-item>
  <el-form-item label="臂展">
    <el-input v-model="list.wingspan"></el-input>
  </el-form-item>
  <el-form-item label="国家">
    <el-input v-model="list.country"></el-input>
  </el-form-item>
  <el-form-item label="生日">
    <el-col :span="11">
      <el-date-picker type="date" placeholder="选择日期" v-model="list.birth" style="width: 100%;"></el-date-picker>
    </el-col>
  </el-form-item>
   <el-form-item label="选秀">
    <el-input v-model="list.draft"></el-input>
  </el-form-item>
   <el-form-item label="薪资">
    <el-input v-model="list.salary"></el-input>
  </el-form-item>
   <el-form-item label="球队">
    <el-input v-model="list.team"></el-input>
  </el-form-item>
  <el-form-item label="号码">
    <el-input v-model="list.number"></el-input>
  </el-form-item>
   <el-form-item label="位置">
    <el-input v-model="list.position"></el-input>
  </el-form-item>
   <el-form-item label="封面" >
    <!-- <el-input v-model="list.cover"></el-input> -->
     <single-upload v-model="list.cover" :floder="this.floder"></single-upload>
  </el-form-item>
 
    <br>
     <el-form-item class="a">
            <el-button type="primary" @click="saveOrUpdate">保存并下一步</el-button>
        </el-form-item>
</el-form>
 </div>
</template>
<script>
import SingleUpload from "@/components/upload/singleUpload"
  export default {
    components:{SingleUpload},
    data() {
      return {
        floder:'player',
        list: {
          name: '',
          height: '',
          wingspan: '',
          country: '',
          birth: '',
          draft: '',
          salary: '',
          team: '',
          number: '',
          weight: '',
          position: '',
          cover: '',
          english: ''

        }
      }
    },
    created(){
      if(this.$route.params.id){
        this.getinformationById()
      }
    },
    methods: {
     addinformation(){
          this.$http({
          url: this.$http.adornUrl('/player/playerinformation/save'),
          method: 'post',
          data:this.list
        }).then(({data}) => {
               this.$message({
                    type:'success',
                    message:'添加球员信息成功！'
                });
               this.$router.push({
                 path:'/player/player-update-basicdate/'+data.id
               });
        })
     },
     updateinformation(){
          this.$http({
          url: this.$http.adornUrl('/player/playerinformation/update'),
          method: 'post',
          data:this.list
        }).then(({data}) => {
               this.$message({
                    type:'success',
                    message:'修改球员信息成功！'
                });
               this.$router.push({
                 path:'/player/player-update-basicdate/'+this.$route.params.id
               });
        })
     },
      saveOrUpdate(){
            if(!this.$route.params.id){
                this.addinformation()
            }else{
                this.updateinformation()
            }
         
        },
    getinformationById(){
          this.$http({
          url: this.$http.adornUrl(`/player/playerinformation/info/${this.$route.params.id}`),
          method: 'post'
        }).then(({data}) => {
              this.list = data.playerInformation
        })
    }
  }
  }
</script>

<style>

  .el-input__inner{
      width: 300px;
    
  }
  .a{
      margin-left:40%
  }
</style>